package com.fg.cloud.common.file;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


/**
 * properties工具类
 * @author around
 * @date 2017-3-16
 */
public class PropertiesUtils {

	
	/**
	 * 获取指定porperties文件流，适用于静态方法体调用
	 * @param propertiesName
	 * @return Properties
	 */
	public static Properties getPropertiesByStatic(String propertiesName) {
		Properties prop = new Properties();
		InputStream input = Object.class.getResourceAsStream("/" + propertiesName);
		
		try {
			prop.load(input);
		} catch (IOException e) {
			System.out.println("计划任务执行失败：SystemTaskImpl.clearDir()，找不到properties文件");
			e.printStackTrace();
		}
		return prop;
	}
	
	
	/**
	 * 获取指定porperties文件流
	 * @param propertiesName
	 * @return Properties
	 */
	public Properties getProperties(String propertiesName) {
		Properties prop = new Properties();
		InputStream input = this.getClass().getResourceAsStream("/" + propertiesName);
		
		try {
			prop.load(input);
		} catch (IOException e) {
			System.out.println("计划任务执行失败：SystemTaskImpl.clearDir()，找不到properties文件");
			e.printStackTrace();
		}
		return prop;
	}
}
